#ifndef HALL_H
#define HALL_H
#include<iostream>
#include<vector>
#include<map>
#include"../Socket/tcpcommunication.h"
#include"../clientarg.h"

using namespace std;

struct Hall_arg
{
    string Hall_name;
    string Hall_passwd;
    string Hall_desp;


    TcpCommunication *creater;
    TcpCommunication *per;
};

class Hall
{
public:
    Hall();
    ClientArg* addTcpCommunciationToWaitQue(TcpCommunication *con);
    int        getHomeId();
    void        rollBackId(int id);
    bool       removeInQueue(TcpCommunication *con);
    bool                  addSeat(Hall_arg arg,TcpCommunication *creator);
    pair<bool,string>     joinSeat(string name, string passwd, TcpCommunication *joiner);
    vector<pair<string,string>> getHallDetail();
    void                        connectLeft(TcpCommunication *con);
private:
    ClientArg *       play_act(TcpCommunication *first, TcpCommunication *second, int home_id);
private:
    char                          homeTag[1024];  //房间id
    vector<TcpCommunication *>    vec;            //等待队列
    std::map<std::string      ,Hall_arg>    m_name_hallinfo;//从名字映射房间信息
    std::map<TcpCommunication*,Hall_arg>    m_link_hallinfo;//从连接信息映射房间信息
};

#endif // HALL_H
